// components/header/header.js
const innerAudioContext = wx.createInnerAudioContext()
// innerAudioContext.autoplay = true
innerAudioContext.src = 'cloud://hjw-0bmtc.686a-hjw-0bmtc-1302701545/FM/night.m4a'
innerAudioContext.onPlay(() => {
  console.log('开始播放')
})
innerAudioContext.onError((res) => {
  console.log(res.errMsg)
  console.log(res.errCode)
})
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    m:"start"
  },
  music(){
    if(this.data.m == "start"){
      this.setData({
        m:"stop"
      })
      innerAudioContext.pause()
    }else{
      this.setData({
        m:"start"
      })
      innerAudioContext.play()
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    music(){
      if(this.data.m == "start"){
        this.setData({
          m:"stop"
        })
        innerAudioContext.pause()
      }else{
        this.setData({
          m:"start"
        })
        innerAudioContext.play()
      }
    }
  }
})
